<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>个人中心-卷云户外</title>
<jsp:include page="personcommonref.jsp"></jsp:include>
<style type="text/css">
div.user_pw_box textarea {
	width: 360px;
	height: 60px;
	border: 1px solid #ccc;
	resize: none;
	padding: 10px;
	margin: 10px;
	font-family: 微软雅黑;
}
</style>
</head>
<body id="user_home">
	<!--user box begin-->
	<div class="user_box">
		<%--	公共头部	 --%>
		<jsp:include page="indexHead.jsp"></jsp:include>
		<!--banner begin-->
		<div class="banner_box">
			<img src="../images/user_banner1.jpg">
		</div>
		<!--banner end-->
		<div class="user_info_box">
			<!--left-->
			<div class="home_left">
				<div class="club_topic_btn">
					<ul id="tags">
						<li class="selectTag"><a
							onclick="selectTag('tagContent0',this)" href="javascript:void(0)">发起的话题</a>
						</li>
						<li><a onclick="selectTag('tagContent1',this)"
							href="javascript:void(0)">回复的话题</a></li>
					</ul>
				</div>
				<div id="tagContent" class="topic">
					<div class="tagContent selectTag" id="tagContent0">
						<ul id="tagContent0_ul">
							<!-- <li>
								<div class="infor">
									<p class="tit">
										<a href="http://bbs.huway.com/forum.php?mod=viewthread&amp;tid=4921721">试试</a><span>04-27
											09:44</span>
									</p>
									<p class="pcoin">
										<span><i class="read" title="查看数"></i>46</span> <span><i class="comments" title="回复数"></i>6</span>
									</p>
								</div>
							</li> -->
						</ul>
						<div class="user_comm_more" id="tagContent0_more">
							<input type="hidden" name="threadpage" value="1" id="threadpage">
						</div>
					</div>
					<div class="tagContent" id="tagContent1">
						<ul id="tagContent1_ul">
							<li>
								<div class="infor">
									<p class="tit">
										<a
											href="http://bbs.huway.com/forum.php?mod=viewthread&amp;tid=4921721">试试</a><span>04-27
											09:44</span>
									</p>
									<p class="pcoin">
										<span>46</span> <span>6</span>
									</p>
								</div></li>
						</ul>
						<div class="user_comm_more" id="tagContent1_more">
							<input type="hidden" name="replypage" value="1" id="replypage">
						</div>
					</div>
				</div>
			</div>
			<!--right-->
			<div class="home_right">
				<!--right top begin-->
				<div class="home_right_top">
					<div class="user_box_lt_bg" style="height: 330px"></div>
					<div class="user_box_lt_cont">
						<div class="user_box_lt_top">
							<div class="user_box_lt_header">
								<img src="${bbsUser.headImg }"> <input type="hidden"
									id="uid" value="1272616">
								<h4>
									${bbsUser.nickName}
									<c:if test="${bbsUser.sex==1}">
										<img src="../images/user_focus_b.png">
									</c:if>
                    				<c:if test="${bbsUser.sex==0}">
										<img src="../images/user_focus_g.png">
									</c:if>
								</h4>
							</div>
							<%-- <div class="user_level">
                                    <div class="user_level_lt">
                                        <div class="user_level_lt_top">
                                            <h4 style="width: 74%;"></h4>
                                        </div>
                                        <div class="user_level_lt_bottom">
                                            <p>
                                                (过街蛮驴Ⅰ)
                                            </p><a href="http://user.huway.com/home#">img src="http://cdn.huway.com/ucstatic/static/web/images/user_help.png?v=1.0"/</a>
                                        </div>
                                    </div>
                                    <div class="user_level_rg">
                                        LV1
                                    </div>
                                </div> --%>
						</div>
						<ul class="user_home_num">
							<li class="first">
								<div>${bbsUser.concernNum }</div>
								<p>关注</p></li>
							<li>
								<div>${bbsUser.fansNum }</div>
								<p>粉丝</p></li>
						</ul>
					</div>
				</div>
				<!--right top end-->
				<!--right bottom begin-->
				<div class="home_right_bottom">
					<div class="home_focus">
						<ul>
							<!-- <li class="left">
                                    <a href="http://user.huway.com/uc/capital"><img src="../images/c_icon07.png">资金账户</a>
                                </li> -->
                            <c:if test="${bbsUser.nickName == session.user.nickName }">
                            	<li class="left"><a href="personinfo.jsp">
								<img src="../images/c_icon07.png">个人设置</a>
								</li>
                            </c:if>
                            <c:if test="${bbsUser.nickName != session.user.nickName }">
								<c:if test="${checkFocusExist==true }">
									<li class="left"><a href="UserAction_cancelFocus.action?bbsUserId=${bbsUser.id }">
									<img src="../images/c_icon07.png">取消关注</a>
									</li>
								</c:if>
								<c:if test="${checkFocusExist == null }">
									<li class="left"><a href="javascript:void(0)" onclick="focusUser(this)" id="UserAction_focusUser.action?focusUserid=${bbsUser.id }">
									<img src="../images/c_icon07.png">关注</a>
									</li>
								</c:if>
							</c:if>
						</ul>
					</div>
					<div class="mate_detail_right">
						<h2>关注</h2>
						<ul class="userpic">
						<c:forEach items="${focusList }" var="focususer">
							<li>
							<a href="UserAction_getPersonHome?uid=${focususer.id }">
								<img class="pic" src="${focususer.headImg }">
							</a>
							<c:if test="${focususer.sex==1 }">
								<img class="icon" src="../images/user_focus_b.png">
							</c:if>
							<c:if test="${focususer.sex==0 }">
								<img class="icon" src="../images/user_focus_g.png">
							</c:if>
							</li>
						</c:forEach>
						</ul>
					</div>
					<div class="mate_detail_right">
						<h2>粉丝</h2>
						<ul class="userpic">
						<c:forEach items="${fansList }" var="fansuser">
							<li>
							<a href="UserAction_getPersonHome?uid=${fansuser.id }">
								<img class="pic" src="${fansuser.headImg }">
							</a> 
							<c:if test="${fansuser.sex==1 }">
								<img class="icon" src="../images/user_focus_b.png">
							</c:if>
							<c:if test="${fansuser.sex==0 }">
								<img class="icon" src="../images/user_focus_g.png">
							</c:if>
							</li>
						</c:forEach>
						</ul>
					</div>
				</div>
				<!--right bottom end-->
			</div>
		</div>
	</div>
	<!--user box end-->
	<script type="text/javascript">
	var bbsUserId = '${bbsUser.id}';
	
	function focusUser(a){
		alert(a.id);
		var user = '${session.user}';
		if (user == null || user == "") {
			location.href = "login.jsp";
		}else{
			location.href = a.id;
		}
	}
	
	function goPagePost(a){
		getPagePost(a);
	}
	function goPageReply(a){
		getPageReply(a);
	}
	
	//获取该用户相关帖子
	function getPagePost(a){
		var url = "";
		if (a!=null && a.id != null && a.id != "") {
			url = a.id;
		}else{
			url = "PostAction_getPageResult3.action";
		}
		var data = {"uid":bbsUserId};
		jQuery.post(url,data,function(callback){
			var obj = eval('(' + callback + ')');
			var posts = obj.page.queryResult;
			var page = obj.page;
			var li = "";
			for (var i =0;i<posts.length;i++) {
				li = li + "<li><div class='infor'><p class='tit'><a href='ReplyAction_singlePost.action?pid="+posts[i].id+"&pagenum=1'>"+posts[i].title+"</a><span></span></p><p class='pcoin'><span><i class='read' title='查看数'></i>"+posts[i].viewNumber+"</span><span><i class='comments' title='回复数'></i>"+posts[i].replyNumber+"</span></p></div></li>";
			}
			jQuery("#tagContent0_ul").html(li);
			//清空上一页下一页
			jQuery("#tagContent0_more").html("");
			if (page.currentPageNo>1) {
				var tagContent0_more = jQuery("#tagContent0_more").html();
				tagContent0_more = tagContent0_more + "<a id='PostAction_getPageResult3.action?pagenum="+(parseInt(page.currentPageNo)-1)+"' onclick='goPagePost(this)' style='padding:2px 5px;display: inline;'>上一页</a>";
				jQuery("#tagContent0_more").html(tagContent0_more);
			}
			if (page.currentPageNo<page.pageCount) {
				var tagContent0_more = jQuery("#tagContent0_more").html();
				tagContent0_more = tagContent0_more + "<a id='PostAction_getPageResult3.action?pagenum="+(parseInt(page.currentPageNo)+1)+"' onclick='goPagePost(this)' style='padding:2px 5px;display: inline;'>下一页</a>";
				jQuery("#tagContent0_more").html(tagContent0_more);
			}
		});
	}
	//获取该用户相关回复的帖子
	function getPageReply(a){
		var url = "";
		if (a!=null && a.id != null && a.id != "") {
			url = a.id;
		}else{
			url = "ReplyAction_personReply2.action";
		}
		var data = {"uid":bbsUserId};
		jQuery.post(url,data,function(callback){
			var obj = eval('(' + callback + ')');
			var posts = obj.page.queryResult;
			var page = obj.page;
			var li = "";
			for (var i =0;i<posts.length;i++) {
				li = li + "<li><div class='infor'><p class='tit'><a href='ReplyAction_singlePost.action?pid="+posts[i].id+"&pagenum=1'>"+posts[i].title+"</a><span></span></p><p class='pcoin'><span><i class='read' title='查看数'></i>"+posts[i].viewNumber+"</span><span><i class='comments' title='回复数'></i>"+posts[i].replyNumber+"</span></p></div></li>";
			}
			jQuery("#tagContent1_ul").html(li);
			//清空上一页下一页
			jQuery("#tagContent1_more").html("");
			if (page.currentPageNo>1) {
				var tagContent1_more = jQuery("#tagContent1_more").html();
				tagContent1_more = tagContent1_more + "<a id='ReplyAction_personReply2.action?pagenum="+(parseInt(page.currentPageNo)-1)+"' onclick='goPageReply(this)' style='padding:2px 5px;display: inline;'>上一页</a>";
				jQuery("#tagContent1_more").html(tagContent1_more);
			}
			if (page.currentPageNo<page.pageCount) {
				var tagContent1_more = jQuery("#tagContent1_more").html();
				tagContent1_more = tagContent1_more + "<a id='ReplyAction_personReply2.action?pagenum="+(parseInt(page.currentPageNo)+1)+"' onclick='goPageReply(this)' style='padding:2px 5px;display: inline;'>下一页</a>";
				jQuery("#tagContent1_more").html(tagContent1_more);
			}
		});
	}
	
	jQuery(document).ready(function(){
		//初始化个人主页的相关帖子
		getPagePost(null);
		getPageReply(null);
		
	});
	function selectTag(showContent,selfObj){
        // 操作标签
        var tag = document.getElementById("tags").getElementsByTagName("li");
        var taglength = tag.length;
        for(i=0; i<taglength; i++){
            tag[i].className = "";
        }
        selfObj.parentNode.className = "selectTag";
        // 操作内容
        for(i=0; j=document.getElementById("tagContent"+i); i++){
            j.style.display = "none";
        }
        document.getElementById(showContent).style.display = "block";
        };
        
        $(function(){
        lock = false;

        /*搜索框获取和失去焦点*/
        $(".search input").focus(function(){
            $(this).parents(".search").addClass("long_search");
        });
        $(".search input").blur(function(){
            $(this).parents(".search").removeClass("long_search");
        });

        /*头部下拉效果*/
        $(".hide").hover(function(){
            $(this).addClass("select");
        },function(){
            $(this).removeClass("select");
        });
        $(".user_news").hover(function(){
            $(this).addClass("news_show");
        },function(){
            $(this).removeClass("news_show");
        });
        $(".user_profile").hover(function(){
            $(this).addClass("profile_show");
        },function(){
            $(this).removeClass("profile_show");
        });

        $('.show_btn').on('click', function(event) {
            var _name = $(this).attr("name");
            if( $("[name="+_name+"]").length > 1 ){
                $("[name="+_name+"]").removeClass("hide_btn");
                $(this).addClass("hide_btn");
            } else {
                if( $(this).hasClass("hide_btn") ){
                    $(this).removeClass("hide_btn");
                } else {
                    $(this).addClass("hide_btn");
                }
            }
            $(this).prev('.pay_way_hide').slideToggle();
            $(this).toggleClass('off');//--设置和移除样式--

        });

        $.divselect("#divselect","#inputselect");
        $.divselect("#cityselect","#cityinput");

        $(".love").find("li").click(function(){
            $(this).toggleClass("select");
        });

        //加载更多
        $("#morethread").click(function(){
            $.get('/home/morethread?page='+$("#threadpage").val()+'&uid='+$("#uid").val(),function(data){
                $("#threadpage").val(data.page);
                if(data.more == '2'){
                    $("#morethread").html('没有更多了').unbind();
                }
                var html = '';
                $.each(data.threads, function(infos, info){
                    if(info.subject) {
                        html += '<li><div class="infor"><p class="tit"><a href="'+info.url
                                +'">'+info.subject
                                +'<\/a><span>'+info.timeTran
                                +'<\/span><\/p><p class="pcoin"><span><i class="read"><\/i>'+info.views
                                +'<\/span><span><i class="comments"><\/i>'+info.replies
                                +'<\/span><\/p><\/div><\/li>';
                    }
                });
                $("#tagContent0").children("ul").append(html);
            });
        });

        //加载更多回复
        $("#morereply").click(function(){
            $.get('/home/morereply?page='+$("#replypage").val()+'&uid='+$("#uid").val(),function(data){
                $("#replypage").val(data.page);
                if(data.more == '2'){
                    $("#morereply").html('没有更多了').unbind();
                }
                var html = '';
                $.each(data.replys, function(infos, info){
                    if(info.subject) {
                        html += '<li><div class="infor"><p class="tit"><a href="'+info.url
                                +'">'+info.subject
                                +'<\/a><span>'+info.timeTran
                                +'<\/span><\/p><p class="pcoin"><span><i class="read"><\/i>'+info.views
                                +'<\/span><span><i class="comments"><\/i>'+info.replies
                                +'<\/span><\/p><\/div><\/li>';
                    }
                });
                $("#tagContent1").children("ul").append(html);

            });
        });

        $("#follow").click(function(){
            var uid = $("#uid").val();
            if(lock){
                return false;
            }
            lock = true;
            $.ajax({
                type: "POST",
                url: "/uc/focus/follow",
                data:{uid:uid},
                dataType: "json",
                success: function(data){
                    lock = false;
                    if(data.status == 2000){
                        alert("关注成功");
                    }else{
                        if(data.status == 2020){
                            alert("已关注");
                        }
                    }
                }
            });
        });

        $("#private").click(function(){
            var pw = '<div class="user_pw_box">'+
                    '<h4>给TA发送短消息<\/h4>'+
                    '<textarea rows="" cols="" id="content" placeholder="输入文字"><\/textarea>'+
                    '<\/div>';
            var pw_box = dialog({
                title: '欢迎',
                content: pw,
                okValue: '发送',
                ok: function () {
                    var content = $("#content").val();
                    var touid = $("#uid").val();
                    if(!content){
                        alert('请输入内容');
                        return false;
                    }
                    if(lock){
                        return false;
                    }
                    lock = true;
                    $.ajax({
                        async: false,
                        type: "POST",
                        url: "/uc/msg/reply",
                        data:{touids:touid,content:content},
                        dataType: "json",
                        success: function(data){
                            if(data.status == 2000){
                                alert("发送成功");
                            }else{
                                alert("发送失败");
                            }
                            lock = false;
                        }
                    });
                },
                cancelValue: '取消',
                cancel: function () {}
            });
            pw_box.showModal();

        })

        });
        </script>
	<!--user box end-->
	<%--	公共底部	 --%>
	<jsp:include page="indexFooter.jsp" />
</body>
</html>